package cn.liit.weixin.core.basic.accesstoken;

import cn.liit.weixin.core.config.Config;


@Deprecated
public class AccessTokenThread extends Thread{
	
	@Override
	public void run() {
		while (true) {
			try {
				AccessToken accessToken = AccessTokenSupport.loadAccessToken(AccessTokenSupport.APIURL,Config.appid, Config.appsecret);
				if(accessToken != null){
					Thread.sleep((accessToken.getExpires_in()-200) * 1000);
				}else{
					Thread.sleep(60 * 1000);//如果access_token为null，60秒后再获取
				}
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
